'use strict';

var express = require('express');
var router = express.Router();
var gdutnews = require('./gdutnews');
var gdutlib = require('./gdutlib');
var jwgl = require('./jwgl');
var getToken = require('./getToken');
var checkBind = require('../middleWare/checkBind')
var bind = require('./bind')
var qiniu = require('./qiniu')
// sign with default (HMAC SHA256)
var jwt = require('jsonwebtoken');
var bodyParser = require('body-parser');
var gdutWall = require('./gdutWall')
var yzmService = require('./yzmService')
var suggestion = require('./suggestion')
var calendar = require('./calendar')
var morningService = require('./morningService')
var cetService = require('./cetService')

const UserController = require('../controllers/UserController');
const PostController = require('../controllers/PostController');
const CommentController = require('../controllers/CommentController');
const GradeController = require('../controllers/GradeController');
const ProxyController = require('../controllers/ProxyController');
var test = require('./test')

router.get('/Proxy', ProxyController.main)
// router.get('/test', GradeController.test)
// router.get('/test2', GradeController.test2);
router.post('/gdutWall/send', PostController.send);
router.get('/gdutWall/getOnePost', PostController.getOnePost);
router.post('/gdutWall/comment', CommentController.comment);

/* GET home page. */
router.get('/', function (req, res, next) {
  res.render('index', { title: 'Express' });
});

router.get('/calendar', calendar.calendar);
router.get('/calendarNext', calendar.calendarNext);
/* 校内新闻 */
router.get('/gdutnews', gdutnews.fetchData);
router.get('/gdutnews/detail', gdutnews.fetchDetailData);

/* 广东工业大学图书馆查询 */
router.post('/gdutlibrary/login', gdutlib.gdutlibLogin);
router.post('/gdutlibrary/book', gdutlib.borrowedBook)
router.get('/gdutlibrary/frequency', gdutlib.frequency);  //获取高频查询
router.get('/gdutlibrary/hotsearch',gdutlib.getHotSearch)
router.get('/gdutlibrary/list', gdutlib.getBookList);
router.get('/gdutlibrary/detail', gdutlib.getBookDetail);   // 必须带上ctrlR, ctrlNo 

/* get Token */
router.get('/getToken', getToken.login)  /* 发送微信小程序code，换取token */

/* cet4/6 */
// router.post('/test', cetService.test)
router.get('/cet/getYzm', yzmService.getCetYzm)
// router.post('/query', cetService.testQuery)
router.post('/cet', cetService.cet)

/*教务系统 */
// router.use('/jwgl/login',checkBind)
router.get('/jwgl/sendYzm',yzmService.sendYZM)
router.post('/jwgl/login',UserController.login)
router.post('/bind', bind.bind);        // 发送的参数应该为 { token : token, username:311400****，password：123456 }
router.post('/jwgl/course', jwgl.course);
router.post('/jwgl/courseNext', jwgl.courseNext);
router.post('/jwgl/exam', jwgl.exam);
router.post('/jwgl/score', jwgl.score);


//七牛云tokene

router.get('/uptoken',qiniu.upFileToken);   //发送需要upload的文件名，获取upload token
//gdutWall 工大墙
/*
router.post('/gdutWall/send',gdutWall.send)           // 发送 token， 文章内容， imgUrl
router.post('/gdutWall/getAllMonents',gdutWall.getAllMonents) // 发送token，获取全部monents
router.post('/gdutWall/getPersonMonents',gdutWall.getPersonMonents) // 发送token，获取全部monents
router.post('/gdutWall/sendComment',gdutWall.sendComment) // 发送token，内容,uuid 进行评论
router.post('/gdutWall/like',gdutWall.like) // 发送token，uuid,进行评论
router.post('/gdutWall/detail',gdutWall.detail) // 发送token，uuid,进行评论
router.post('/gdutWall/del',gdutWall.del) // 发送token，uuid,进行删除校内圈 
router.post('/gdutWall/testgetAllMonents',test.testgetAllMonents) //测试分页
*/


//反馈建议
router.post('/suggestion',suggestion) //发送 token 和 suggestion

module.exports = router;
